package com.njcs.Inconsistentsynchronization;

/**
 * @author Sam.Lee E-mail:lishanman2007@163.com
 * @version Created：Jul 28, 2011 9:12:47 AM
 */
public class ObjectClass extends Thread {
	private ObjClass2 obj;
	private Object lockTable = new Object();

	public ObjectClass() {
		obj = new ObjClass2();
	}

	public void setObj(ObjClass2 obj) {
		synchronized (lockTable) {
			this.obj = obj;
		}
	}

	public ObjClass2 getObj() {
		synchronized (lockTable) {
			return this.obj; // 出问题处！！
		}
	}

	public void Loop() {
		synchronized (lockTable) {
			while (true) {
				System.out.println(obj.str);
			}
		}
	}
}
